import Vue from "vue";
import Vuex from "vuex"; //引入vuex
Vue.use(Vuex); //使用vuex

export default new Vuex.Store({
  state: {
    shoppingCount: sessionStorage.getItem(
      `${sessionStorage.getItem("uid")}-shoppingCount`
    )
      ? + sessionStorage.getItem(`${sessionStorage.getItem("uid")}-shoppingCount`)
      : 0,
  },
  mutations: {
    addShoppingCart(state) {
      state.shoppingCount = state.shoppingCount + 1;
    },
  },
  actions: {},
  modules: {},
});
